<?php
class DetailsController extends AppController{
	function add($filename){
		App::import('Model', 'Upload');
		$Upload=new Upload();
		$data=$Upload->find('first',array('order' => 'id DESC'));
		$id=$data['Upload']['id'];			
		$this->data['Detail']['upload_id']=$id;		
		$this->data['Detail']['name']=$filename;		
		$this->data['Detail']['isupload']=0;
		
		$this->Detail->save($this->data);		
	}
	function index($uploadid=0, $date=null, $hospitalname){
		$data=$this->Detail->findAll("upload_id=".$uploadid." and isupload=0");
		$this->set('hospitalname', $hospitalname);
		$this->set('data', $data);
		$this->set('i',1);
		$this->set('date', $date);
	}
	function setStatus($detailid, $status){
		$this->data['Detail']['id']=$detailid;
		$this->data['Detail']['isupload']=$status;
		
		$this->Detail->save($this->data);
	}
	function update($uploadid){
		$data=$this->Detail->findAllByUpload_id(0);				
		foreach($data as $row){
			$this->data['Detail']['id']=$row['Detail']['id'];			
			$this->data['Detail']['upload_id']=$uploadid;
			
			$this->Detail->save($this->data);
		}		
	}
}
?>